ng-book 2 by Felipe Coury Ari Lerner Nate Murray && Carlos Taborda
Author:Felipe Coury, Ari Lerner, Nate Murray, && Carlos Taborda
Language: eng
Format: mobi
Publisher: leanpub.com
Published: 2016-09-02T04:00:00+00:00
One other detail, since we’re already looking that the messages for the current thread, this is a convenient area to mark these messages as read.
code/rxjs/chat/app/ts/services/ThreadsService.ts 54 return _.chain(messages) 55 .filter((message: Message) => 56 (message.thread.id === currentThread.id)) 57 .map((message: Message) => { 58 message.isRead = true; 59 return message; }) 60 .value();
Whether or not we should be marking messages as read here is debatable. The biggest drawback is that we’re mutating objects in what is, essentially, a “read” thread. i.e. this is a read operation with a side effect, which is generally a Bad Idea. That said, in this application the currentThreadMessages only applies to the currentThread and the currentThread should always have its messages marked as read. That said, the “read with side-effects” is not a pattern I recommend in general.
Putting it together, here’s what currentThreadMessages looks like:
code/rxjs/chat/app/ts/services/ThreadsService.ts 50 this.currentThreadMessages = this.currentThread 51 .combineLatest(messagesService.messages, 52 (currentThread: Thread, messages: Message[]) => { 53 if (currentThread && messages.length > 0) { 54 return _.chain(messages) 55 .filter((message: Message) => 56 (message.thread.id === currentThread.id)) 57 .map((message: Message) => { 58 message.isRead = true; 59 return message; }) 60 .value(); 61 } else { 62 return []; 63 } 64 });
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
The Mikado Method by Ola Ellnestam Daniel Brolund(22076)
Hello! Python by Anthony Briggs(21280)
Secrets of the JavaScript Ninja by John Resig Bear Bibeault(19801)
Dependency Injection in .NET by Mark Seemann(19267)
The Well-Grounded Java Developer by Benjamin J. Evans Martijn Verburg(18963)
Kotlin in Action by Dmitry Jemerov(18842)
OCA Java SE 8 Programmer I Certification Guide by Mala Gupta(18469)
Algorithms of the Intelligent Web by Haralambos Marmanis;Dmitry Babenko(17315)
Adobe Camera Raw For Digital Photographers Only by Rob Sheppard(16957)
Grails in Action by Glen Smith Peter Ledbrook(16453)
Test-Driven iOS Development with Swift 4 by Dominik Hauser(10785)
Becoming a Dynamics 365 Finance and Supply Chain Solution Architect by Brent Dawson(8063)
Microservices with Go by Alexander Shuiskov(7827)
Practical Design Patterns for Java Developers by Miroslav Wengner(7729)
Test Automation Engineering Handbook by Manikandan Sambamurthy(7687)
Angular Projects - Third Edition by Aristeidis Bampakos(7173)
The Art of Crafting User Stories by The Art of Crafting User Stories(6620)
NetSuite for Consultants - Second Edition by Peter Ries(6542)
Demystifying Cryptography with OpenSSL 3.0 by Alexei Khlebnikov(6312)